/* Copyright(C) 2006-2008 Dave Sexton  *
 * http://www.codeplex.com/aip         *
 * http://www.codeplex.com/aip/license *
 ***************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace DaveSexton.Web.Controls.Configuration
{
	/// <summary>
	/// Provides programmatic access to the <c>&lt;autoInputProtection&gt;</c> configuration file section.
	/// </summary>
	public sealed class AutoInputProtectionSection : ConfigurationSection
	{
		#region Public Properties
		/// <summary>
		/// Gets a <see cref="ProviderSettingsCollection"/> collection of <see cref="ProviderSettings"/> objects for the
		/// <see cref="AutoInputProtectionTextProvider"/> implementations that are configued.
		/// </summary>
		[ConfigurationProperty("textProviders")]
		public ProviderSettingsCollection TextProviders
		{
			get
			{
				return (ProviderSettingsCollection) base["textProviders"];
			}
		}

		/// <summary>
		/// Gets a <see cref="ProviderSettingsCollection"/> collection of <see cref="ProviderSettings"/> objects for the
		/// <see cref="AutoInputProtectionImageProvider"/> implementations that are configued.
		/// </summary>
		[ConfigurationProperty("imageProviders")]
		public ProviderSettingsCollection ImageProviders
		{
			get
			{
				return (ProviderSettingsCollection) base["imageProviders"];
			}
		}

		/// <summary>
		/// Gets a <see cref="ProviderSettingsCollection"/> collection of <see cref="ProviderSettings"/> objects for the
		/// <see cref="AutoInputProtectionFilterProvider"/> implementations that are configued.
		/// </summary>
		[ConfigurationProperty("filters")]
		public ProviderSettingsCollection FilterProviders
		{
			get
			{
				return (ProviderSettingsCollection) base["filters"];
			}
		}

		/// <summary>
		/// Gets or sets the name of the default <see cref="AutoInputProtectionImageProvider"/> from the <see cref="ImageProviders"/> collection.
		/// </summary>
		[StringValidator(MinLength = 1)]
		[ConfigurationProperty("defaultImageProvider", DefaultValue = "LineNoiseAutoInputProtectionImageProvider")]
		public string DefaultImageProvider
		{
			get
			{
				return (string) base["defaultImageProvider"];
			}
			set
			{
				base["defaultImageProvider"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the name of the default <see cref="AutoInputProtectionTextProvider"/> from the <see cref="TextProviders"/> collection.
		/// </summary>
		[StringValidator(MinLength = 1)]
		[ConfigurationProperty("defaultTextProvider", DefaultValue = "BasicEnglishAutoInputProtectionTextProvider")]
		public string DefaultTextProvider
		{
			get
			{
				return (string) base["defaultTextProvider"];
			}
			set
			{
				base["defaultTextProvider"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the <see cref="AutoInputProtectionUserMode"/> that specifies how users are identified by <see cref="AutoInputProtection"/>.  
		/// The default value is <see cref="AutoInputProtectionUserMode.Client"/>, which indicates that AIP will identify users by host address or host name.
		/// </summary>
		/// <seealso cref="PersistenceMode"/>
		/// <seealso cref="AutoInputProtection"/>
		[ConfigurationProperty("userMode", DefaultValue = AutoInputProtectionUserMode.Client)]
		public AutoInputProtectionUserMode UserMode
		{
			get
			{
				return (AutoInputProtectionUserMode) base["userMode"];
			}
			set
			{
				base["userMode"] = value;
			}
		}

		/// <summary>
		/// Gets or sets the <see cref="AutoInputProtectionPersistenceMode"/> that specifies where the AIP image and text will be stored on the server.
		/// The default value is <see cref="AutoInputProtectionPersistenceMode.Cache"/>, which indicates that the ASP.NET Cache will be used exclusively.
		/// </summary>
		/// <remarks>
		/// <include file='comments.xml' path='//para[@id="PersistenceMode_Session_Timeouts"]'/>
		/// <include file='comments.xml' path='//para[@id="ASPNET_New_SessionID"]'/>
		/// </remarks>
		/// <seealso cref="UserMode"/>
		/// <seealso cref="AutoInputProtection"/>
		[ConfigurationProperty("persistenceMode", DefaultValue = AutoInputProtectionPersistenceMode.Cache)]
		public AutoInputProtectionPersistenceMode PersistenceMode
		{
			get
			{
				return (AutoInputProtectionPersistenceMode) base["persistenceMode"];
			}
			set
			{
				base["persistenceMode"] = value;
			}
		}
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="AutoInputProtectionSection" /> class.
		/// </summary>
		public AutoInputProtectionSection()
		{
		}
		#endregion
	}
}
